package com.licode.codekit;

import com.intellij.ide.IdeView;
import com.intellij.openapi.actionSystem.AnAction;
import com.intellij.openapi.actionSystem.AnActionEvent;
import com.intellij.openapi.actionSystem.LangDataKeys;
import com.intellij.openapi.project.Project;
import com.intellij.psi.PsiDirectory;
import com.licode.codekit.buildprj.CreateModuleUI;
import org.jetbrains.annotations.NotNull;

/**
 * @author licode
 */
public class BuildModuleKit extends AnAction {

    @Override
    public void update(@NotNull AnActionEvent e) {
        ActionEventUtil.handleEvent(e);
        super.update(e);
    }

    @Override
    public void actionPerformed(AnActionEvent e) {
        IdeView ideView = e.getRequiredData(LangDataKeys.IDE_VIEW);
        // 选择的文件夹
        PsiDirectory psiDirectory = ideView.getOrChooseDirectory();
        // 选择的项目
        Project project = psiDirectory.getProject();
        String currPrj = psiDirectory.getVirtualFile().getPath();

        CreateModuleUI autoCodeUI = new CreateModuleUI(project, currPrj);
        autoCodeUI.setResizable(true);
        autoCodeUI.show();
    }
}
